package codegen.builders;

import java.io.BufferedWriter;
import java.io.IOException;

public class CodegenClass extends CodegenType {

	public CodegenClass(String simnpleName) {
		super(simnpleName);
	}

	public CodegenInterface extractInterface(CodegenType cgClass, String interfaceName) {
		CodegenInterface cgInterface = new CodegenInterface(interfaceName);
		cgInterface.packageName(cgClass.getPackageName());
		logger.debug("<======== Extracting interface ==========>");
		for (CodegenMethod method : methods.values()) {
			logger.debug(method.getName() + " is in interface = " + method.isInInterface());
			if (method.isInInterface()) {
				cgInterface.addMethod(method);
			}
		}
		implement(cgInterface.fullName());
		return cgInterface;
	}

	@Override
	protected void writeClassOpen(BufferedWriter fw) throws IOException {
		doWriteClassOpen(false, fw);
	}

}
